package com.lrkj.property.controller;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.property.domain.SiteManag;
import com.lrkj.property.service.ISiteManagService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 场地管理Controller
 *
 * @author yajun_ren
 * @date 2022-03-16
 */
@RestController
@RequestMapping("/property/siteManag")
@Api(tags = "场地管理")
public class SiteManagController extends BaseController
{
    @Autowired
    private ISiteManagService siteManagService;

    /**
     * 查询场地管理列表
     */
    @ApiOperation(value = "查询场地管理列表", notes = "查询场地管理列表")
    @PreAuthorize("@ss.hasPermi('property:siteManag:list')")
    @GetMapping("/list")
    public TableDataInfo list(SiteManag siteManag)
    {
        startPage();
        this.changeParameter(siteManag.getParams());
        List<SiteManag> list = siteManagService.selectSiteManagList(siteManag);
        return getDataTable(list);
    }

    /**
     * 导出场地管理列表
     */
	@ApiOperation(value = "导出场地管理列表", notes = "导出场地管理列表")
    @PreAuthorize("@ss.hasPermi('property:siteManag:export')")
    @Log(title = "场地管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SiteManag siteManag)
    {
        List<SiteManag> list = siteManagService.selectSiteManagList(siteManag);
        ExcelUtil<SiteManag> util = new ExcelUtil<SiteManag>(SiteManag.class);
        return util.exportExcel(list, "场地管理数据");
    }

    /**
     * 获取场地管理详细信息
     */
	@ApiOperation(value = "获取场地管理详细信息", notes = "获取场地管理详细信息")
    @PreAuthorize("@ss.hasPermi('property:siteManag:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(siteManagService.selectSiteManagById(id));
    }

    /**
     * 新增场地管理
     */
    @ApiOperation(value = "新增场地管理", notes = "新增场地管理")
    @PreAuthorize("@ss.hasPermi('property:siteManag:add')")
    @Log(title = "场地管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SiteManag siteManag)
    {
        return toAjax(siteManagService.insertSiteManag(siteManag));
    }

    /**
     * 修改场地管理
     */
    @ApiOperation(value = "修改场地管理", notes = "修改场地管理")
    @PreAuthorize("@ss.hasPermi('property:siteManag:edit')")
    @Log(title = "场地管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SiteManag siteManag)
    {
        return toAjax(siteManagService.updateSiteManag(siteManag));
    }

    /**
     * 删除场地管理
     */
    @ApiOperation(value = "删除场地管理", notes = "删除场地管理")
    @PreAuthorize("@ss.hasPermi('property:siteManag:remove')")
    @Log(title = "场地管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(siteManagService.deleteSiteManagByIds(ids));
    }



    /**
     * 通过场地ID,获取场地车位数量和使用情况
     */
    @ApiOperation(value = "通过场地ID,获取场地车位数量和使用情况", notes = "通过场地ID,获取场地车位数量和使用情况")
    @GetMapping(value = "/getSitePostInfo/{siteId}")
    public AjaxResult getSitePostInfo(@PathVariable("siteId") String siteId) {
        return AjaxResult.success(siteManagService.getSitePostInfo(siteId));
    }
}
